package com.wit.example.share;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

/**
* 用于在fragment之间共享数据
*
* @Author liaozhaoping
* @Date 2024/5/21 10:35
*/
public class SharedViewModel extends ViewModel {
    private MutableLiveData<float[]> dataArray = new MutableLiveData<>();
    private MutableLiveData<String> dataString = new MutableLiveData<>();

    public void setDataArray(float[] values) {
        dataArray.setValue(values);
    }

    public LiveData<float[]> getDataArray() {
        return dataArray;
    }

    public void postFloatArray(float[] floatArray) {
        dataArray.postValue(floatArray);
    }

    public void postDataString(String value) {
        dataString.postValue(value);
    }

    public LiveData<String> getDataString() {
        return dataString;
    }


}
